﻿using System;


namespace AppMain
{
    public class BaseAttr<T> : IAttr where T : IEquatable<T>
    {
        protected short type;
        public short Type
        {
            get
            {
                return this.type;
            }
        }
        protected T value;
        public T Value
        {
            get
            {
                return this.value;
            }
            set
            {
                if (this.value == null || !this.value.Equals(value))
                {
                    this.value = value;
                    if (onAttrChange != null)
                    {
                        onAttrChange(this.value);
                    }
                }
            }
        }
        public event Action<T> onAttrChange;

        public BaseAttr(short attrType, T value)
        {
            this.type = attrType;
            this.value = value;
        }
    }
}
